home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: Virtual Function in private part?
- Date: 7 Feb 1996 12:14:16 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4fa52o$pkb@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 06, 1996 10:29:52 in article <Virtual Function in private part?>,
- 'g9326161@mcmail.cis.McMaster.CA (Hong Shen)' wrote:
-
-
- >Is there any reasons to make a member function in the private section of
- >a class virtual?
- >
- Sure, for example:
-
- class A { public:
- void Expand { Left = MakeChild(); Right = MakeChild(); }
- private:
- virtual A * MakeChild() { return new A; }
- A * Left; A * Right;
- };
-
- class B {
- private:
- virtual A* MakeChild() { return new B; }
- };
-
- Now, when you call Expand, the appropriate types of
- objects will be constructed.
-
-
-
- >Thanks.
- >
- >Hong Shen
- >
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-